package web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.Typeservice;
import util.web.ServletUtil;

public class TypeEdit extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Typeservice typeservice = new Typeservice();
		String id = request.getParameter("id");
		boolean b = typeservice.typedel(id);
		if (b) {
			ServletUtil.sendRedirect(response, "/admin/typelist.jspx");
		}else {
			ServletUtil.sendRedirect(response, "/admin/typelist.jspx?state=1001");
		}
		
	}
	
	
	
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		Typeservice typeservice = new Typeservice();
		
		String typename = request.getParameter("typename");
		String id = request.getParameter("myid");
		
		typeservice.typeEdit(typename,id);
		
		ServletUtil.sendRedirect(response, "/admin/typelist.jspx");
	}

}
